import 'dart:math';

import 'package:flutter/material.dart';
import 'package:jg_docs/features/app_size_monitor.dart';
import 'package:jg_docs/features/features.dart';

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
  late TabController controller;

  @override
  void initState() {
    super.initState();
    controller = TabController(length: 4, initialIndex: 0, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      drawer: SizedBox(
        width: max(MediaQuery.of(context).size.width * 0.1, 300.0),
        child: CatalogPage(),
      ),
      appBar: AppBar(
        title: Text('$runtimeType'),
        bottom: TabBar(
          controller: controller,
          tabs: [
            Tab(text: '/docs'),
            Tab(text: '/discover'),
            Tab(text: '/metrics'),
            Tab(text: '/appSize'),
          ],
          onTap: (index) {
            controller.animateTo(index);
          },
        ),
      ),
      body: Row(
        children: [
          SizedBox(
            width: max(MediaQuery.of(context).size.width * 0.1, 300.0),
            child: CatalogPage(),
          ),
          Expanded(
            child: TabBarView(
              controller: controller,
              children: [
                DocsPage(),
                DiscoverPage(),
                MetricsPage(),
                AppSizeMonitorPage(),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
